﻿using Demo.Model.DatabaseContext;
using Demo.Model.Tables;
using System;
using System.Data.Entity;
using System.Data.Entity.Migrations;
using System.Linq;
namespace Demo.Model.Migrations
{
    public class CustomMigrations : DropCreateDatabaseAlways<ProductContext>
    {
        protected override void Seed(ProductContext context)
        {            
                var Items = Enumerable.Range(1, 50).Select(x => new Products()
                {
                    Price = x * 100,
                    Quantity = x,
                    Name = "Product" + x,
                    Description = "Product Description" + x
                }).ToArray();

                context.Product.AddOrUpdate<Products>(x => new { x.ID }, Items);
                context.SaveChanges();
                base.Seed(context);
            
        }
    }
}
